package com.house.rent.util;


import android.content.Context;

import com.base.lib.util.BasePreferences;
import com.base.lib.util.JSONUtils;
import com.house.rent.App;
import com.house.rent.Constants;
import com.house.rent.entity.UserEntity;


/**
 * @desc preferences操作工具类
 */
public class PreferencesUtils extends BasePreferences {
    private static Context context = App.getInstance();

    public static void putUserEntity(UserEntity userEntity) {
        putString(context, "user", JSONUtils.getJsonString(userEntity));
    }

    public static UserEntity getUserEntity() {
        String json = getString(context, "user", "");
        UserEntity userEntity = JSONUtils.parseObject(json, UserEntity.class);
        if (userEntity == null) {
            userEntity = new UserEntity();
        }
        return userEntity;
    }

    public static void putBaseUrl(String url) {
        putString(context, "base_url", url);
    }

    public static String getBaseUrl() {
        return getString(context, "base_url", Constants.DEFAULT_SERVER_URL);
    }


}
